<div class="templatemo-content-wrapper">
	<div class="templatemo-content">
		 <style type="text/css">
		.train-logo .logo-pic{
			position: absolute;
			right:15px;
			top:10px;
			border:1px #eee solid;
			padding:2px;
		}

		#ui-datepicker-div{
			z-index: 99999 !important;
		}
		</style>
		 <ul class="nav nav-tabs mytabs">
		  <li class="active"><a href="#">编辑文章</a></li>
		  <li ><a href="<?=site_url()?>/article/index">文章列表</a></li>
		  <li role="presentation"><a href="<?=site_url()?>/article/add"><i class="fa fa-plus"></i> 添加文章</a></li>
		 
		</ul>
		<div class="row">
			<div class="col-md-12">
				<div class="table-responsive">
					 
					<form role="form" id="templatemo-preferences-form"
						onsubmit="return false;">
						<div class="row">
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">标题</label> 
								<input type="text" class="form-control" id="title" value="<?=$article['title']?>">
							</div>
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">分 类</label> 
								<select class="form-control margin-bottom-15" id="category">
                   						<?php foreach ($categories as $item):?>
                   						<option value="<?php echo $item['id'];?>" <?php if($item['id'] == $article['class']) echo "selected"; ?>><?php echo $item['name'];?></option>
                     					<?php endforeach;?>
                  				</select>
							</div>
						</div>
						<div class="row">
							<div class="col-md-6 margin-bottom-15">
								<label for="firstName" class="control-label">详细内容</label> 
								<script id="editor" type="text/plain" style="width:1024px;height:500px;"><?=$article['content']?></script>
							</div>
						</div>
						<div class="row templatemo-form-buttons">
							<div class="col-md-12">
								<input type="hidden" id="id" value="<?=$article['id']?>" />
								<button type="submit" class="btn btn-primary" id="submit_btn">修改</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	$(document).ready(function() {
		var ue = UE.getEditor('editor');
		
		$("#submit_btn").click(function() {
			var id = $("#id").val();
			var title = $("#title").val();
			var category = $("#category").val();
			var editor = ue.getContent();
			$.ajax({
				url : '<?php echo site_url('article/save')?>',
				type : "post",
				async : true,
				data : {
					'id' : id,
					'title' : title,
					'category' : category,
					'editor' : editor
				},
				dataType : "json",
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
					}else{
						alert(data.msg);
					}
				}
			});
		});
	
	}); 
</script>